<?php
/**
 * @filename AbstractDuckFactory.php
 * @author LD King
 * @encoding UTF-8
 * @date 2008-9-19 | 下午04:22:18
 * @package 12-MVC
 * @subpackage 
 * @usage 鸭子批量生产车间 ── 抽象工厂
 * @note 
 * @copyright Copyright (c) 2007 - 2008 LD (http://mifunny.info)
 * @version $Id: $
 */

include_once 'Quackable.php';

/**
 * 添加计数器
 */
include_once 'QuackCounter.php';

/**
 * 把鹅当成 鸭子来用 …… 工厂还在这里
 */
include_once 'Goose.php';


/**
 * 鸭子 抽象工厂
 *
 */
abstract class AbstractDuckFactory {
	
	/**
	 * 创建鸭子对象
	 *
	 * @return Quackable
	 */
	public abstract function createMallardDuck();
	public abstract function createRedheadDuck();
	public abstract function createDuckCall();
	public abstract function createRubberDuck();
	
	/**
	 * 鹅假装鸭子
	 */
	public abstract function createGoose();
	
} /* END class AbstractDuckFactory */

/**
 * 没有装饰者的工厂方法
 *
 */
class DuckFactory extends AbstractDuckFactory {
	/**
	 * @see AbstractDuckFactory::createDuckCall()
	 *
	 */
	public function createDuckCall() {
		return new DuckCall();
	}
	
	/**
	 * @see AbstractDuckFactory::createMallardDuck()
	 *
	 * @return Quackable
	 */
	public function createMallardDuck() {
		return new MallardDuck();
	}
	
	/**
	 * @see AbstractDuckFactory::createRedheadDuck()
	 *
	 */
	public function createRedheadDuck() {
		return new RedheadDuck();
	}
	
	/**
	 * @see AbstractDuckFactory::createRubberDuck()
	 *
	 */
	public function createRubberDuck() {
		return new RubberDuck();
	}
	
	/**
	 * @see AbstractDuckFactory::createGoose()
	 *
	 */
	public function createGoose() {
		return new GooseAdapter(new Goose());
	}

} /* END class DuckFactory */

/**
 * 添加了计数器的 装饰者工厂
 *
 */
class CountingDuckFactory extends AbstractDuckFactory {
	/**
	 * @see AbstractDuckFactory::createDuckCall()
	 *
	 */
	public function createDuckCall() {
		return new QuackCounter(new DuckCall());
	}
	
	/**
	 * @see AbstractDuckFactory::createMallardDuck()
	 *
	 * @return Quackable
	 */
	public function createMallardDuck() {
		return new QuackCounter(new MallardDuck());
	}
	
	/**
	 * @see AbstractDuckFactory::createRedheadDuck()
	 *
	 */
	public function createRedheadDuck() {
		return new QuackCounter(new RedheadDuck());
	}
	
	/**
	 * @see AbstractDuckFactory::createRubberDuck()
	 *
	 */
	public function createRubberDuck() {
		return new QuackCounter(new RubberDuck());
	}
	
	/**
	 * @see AbstractDuckFactory::createGoose()
	 *
	 */
	public function createGoose() {
		return new GooseAdapter(new Goose());
	}

} /* END class CountingDuckFactory */

?>